﻿// ===============================================================================
// Copyright(c) 2007-2020 西安交通信息投资营运有限公司 版权所有
// 作者:马星俊
// ===============================================================================

using System.Threading.Tasks;
using XCI.Core;
using XCI.Extensions;
using XCI.Sys.Forms;
using XCI.Sys.Model;
using XCI.Sys.Service;

namespace XCI.Windows
{
    public partial class UserListRoleControl : BaseUserControl
    {
        private string _primaryKey;
        public UserListRoleControl()
        {
            InitializeComponent();
            gridControl.ModelType = typeof(SysUser);
        }

        public async Task LoadAsync(string primaryKey)
        {
            _primaryKey = primaryKey;
            await gridControl.LoadAsync();
        }

        private void GridControl_LoadData(object sender, LoadDataEventArgs e)
        {
            e.Task = async () => new PagingList<SysUser>(await SysAccountService.Instance.SelectRelationUserListAsync(_primaryKey));
        }

        private void GridControl_RowDoubleClick(object sender, System.EventArgs e)
        {
            new FrmUserDetails(gridControl).ShowDialogOk();
        }
    }
}
